<?php
class Master extends TTemplateControl
{
	public function onInit($param)
	{
		parent::onInit($param);
		date_default_timezone_set('Asia/Singapore');
		if (!$this->Page->IsPostBack)
		{	
			if ($this->Application->User->UserName != "") 
			{
				$this->lblWelcome->Text = "Welcome ";
				$this->lnkProfile->Text = $this->Application->User->FirstName . " " . $this->Application->User->LastName;
				if (Common::checkAdmin($this->Application->User))
					$this->lnkAdmin->Visible=true;					
				$this->lblWelcome->Visible = true;				
				$this->lnkProfile->Visible = true;				
				$this->lblLine1->Visible = true;
				$this->lblLine2->Visible = true;
				$this->lnkLogOut->Visible = true;				
			}
			
			$items = CartTempDetailRecord::finder()->findAllBysession_id($this->Session->SessionID);				
			$this->lnkShoppingCart->Text = "My Shopping Cart (" . count($items) . ")";
		}		
	}
	
	protected function getUrlPrefix()
	{
		return $this->Request->UrlManagerModule->UrlPrefix;
	}	
	
	protected function btnLogout_Clicked($sender, $param)
	{
		$this->Application->getModule("auth")->logout();
		$this->Response->redirect($this->Service->ConstructUrl("Index"));
	}	
}
?>